package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoPrintingDoor;
import com.muyu.danmo.service.IDanmoPrintingDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 印刷出版门头Controller
 *
 * @author yangle
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/printingDoor")
public class DanmoPrintingDoorController extends BaseController
{
    @Autowired
    private IDanmoPrintingDoorService danmoPrintingDoorService;

    /**
     * 查询印刷出版门头列表
     */
//    @RequiresPermissions("system:printingDoor:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoPrintingDoor>> list(DanmoPrintingDoor danmoPrintingDoor)
    {
        startPage();
        List<DanmoPrintingDoor> list = danmoPrintingDoorService.selectDanmoPrintingDoorList(danmoPrintingDoor);
        return getDataTable(list);
    }

    /**
     * 导出印刷出版门头列表
     */
//    @RequiresPermissions("system:printingDoor:export")
    @Log(title = "印刷出版门头", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoPrintingDoor danmoPrintingDoor)
    {
        List<DanmoPrintingDoor> list = danmoPrintingDoorService.selectDanmoPrintingDoorList(danmoPrintingDoor);
        ExcelUtil<DanmoPrintingDoor> util = new ExcelUtil<DanmoPrintingDoor>(DanmoPrintingDoor.class);
        util.exportExcel(response, list, "印刷出版门头数据");
    }

    /**
     * 获取印刷出版门头详细信息
     */
//    @RequiresPermissions("system:printingDoor:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoPrintingDoorService.selectDanmoPrintingDoorById(id));
    }

    /**
     * 新增印刷出版门头
     */
//    @RequiresPermissions("system:printingDoor:add")
    @Log(title = "印刷出版门头", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoPrintingDoor danmoPrintingDoor)
    {
        return toAjax(danmoPrintingDoorService.insertDanmoPrintingDoor(danmoPrintingDoor));
    }

    /**
     * 修改印刷出版门头
     */
//    @RequiresPermissions("system:printingDoor:edit")
    @Log(title = "印刷出版门头", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoPrintingDoor danmoPrintingDoor)
    {
        return toAjax(danmoPrintingDoorService.updateDanmoPrintingDoor(danmoPrintingDoor));
    }

    /**
     * 删除印刷出版门头
     */
//    @RequiresPermissions("system:printingDoor:remove")
    @Log(title = "印刷出版门头", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoPrintingDoorService.deleteDanmoPrintingDoorByIds(ids));
    }
}
